package com.android.taskmanager;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

import com.android.taskmanager.app.Application;
import com.android.taskmanager.battery.Battery;
import com.android.taskmanager.bluetooth.Bluetooth;
import com.android.taskmanager.cpu.CPU;
import com.android.taskmanager.ggg.GGG;
import com.android.taskmanager.gps.GPS;
import com.android.taskmanager.memory.Memory;
import com.android.taskmanager.network.Network;
import com.android.taskmanager.ram.Ram;
import com.android.taskmanager.setting.Setting;
import com.android.taskmanager.volume.Volume;
import com.android.taskmanager.wifi.Wifi;

public class TaskManager extends Activity {
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        GridView gridView = (GridView) findViewById(R.id.gridView1);
        gridView.setAdapter(new ViewComponent(this));
        gridView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
				// TODO Auto-generated method stub
	             switch(arg2){
	             case 0:
	            	 Intent i = new Intent(getApplicationContext(), Application.class);
	            	 startActivity(i);
	            	 break;
	             case 1:
	            	 Intent i1 = new Intent(getApplicationContext(), Battery.class);
	            	 startActivity(i1);
	            	 break;
	             case 2:
	            	 Intent i2 = new Intent(getApplicationContext(), Bluetooth.class);
	            	 startActivity(i2);
	            	 break;
	             case 3:
	            	 Intent i3 = new Intent(getApplicationContext(), CPU.class);
	            	 startActivity(i3);
	            	 break;
	             case 4:
	            	 Intent i4 = new Intent(getApplicationContext(), GGG.class);
	            	 startActivity(i4);
	            	 break;
	             case 5:
	            	 Intent i5 = new Intent(getApplicationContext(), GPS.class);
	            	 startActivity(i5);
	            	 break;
	             case 6:
	            	 Intent i6 = new Intent(getApplicationContext(), Memory.class);
	            	 startActivity(i6);
	            	 break;
	             case 7:
	            	 Intent i7 = new Intent(getApplicationContext(), Network.class);
	            	 startActivity(i7);
	            	 break;
	             case 8:
	            	 Intent i8 = new Intent(getApplicationContext(), Ram.class);
	            	 startActivity(i8);
	            	 break;
	             case 9:
	            	 Intent i9 = new Intent(getApplicationContext(), Setting.class);
	            	 startActivity(i9);
	            	 break;
	             case 10:
	            	 Intent i10 = new Intent(getApplicationContext(), Volume.class);
	            	 startActivity(i10);
	            	 break;
	             case 11:
	            	 Intent i11 = new Intent(getApplicationContext(), Wifi.class);
	            	 startActivity(i11);
	            	 break;
	             }
			}
		});
        
        
    }

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		menu.add(0, 11, 0, "Refresh");
		menu.add(0, 12, 1, "Exit");
		menu.add(0, 13, 2, "About");
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onMenuItemSelected(int featureId, MenuItem item) {
		// TODO Auto-generated method stub
		switch (item.getItemId())
		{
		case 11:
		//Do something
			Toast.makeText(getApplicationContext(), "Item", Toast.LENGTH_SHORT).show();
		break;
		case 12:
		//Do something
			
		break;
		case 13:
		//Do something
			Toast.makeText(getApplicationContext(), "Item", Toast.LENGTH_SHORT).show();
		break;
		}
		return super.onMenuItemSelected(featureId, item);
	}
    
}

// Hf3Sc2Yq5xU3